<template>
	<view class="withdrawlog-container pages">
		<!-- 头部 -->
		<pagehead pagesPath="/pages/asset/withdrawal">提现记录</pagehead>
		<view class="withdrawlog-content" v-if="isShowPage">
			<!-- <scroll-view scroll-y class="withdrawlog-scroll" @scrolltolower="lower()" v-if="isShowPage"> -->
				<view class="withdrawlog-list" v-if="withdrawList.length != 0">
					<view v-for="(item,index) in withdrawList" :key="index" class="withdrawlog-item">
						<view class="info">
							<view class="label">订单号</view>
							<view class="des">{{ item.order_no }}</view>
						</view>
						<view class="info">
							<view class="label">申请提现金额</view>
							<view class="des">{{ (item.cash_money) }}</view>
						</view>
						<view class="info">
							<view class="label">手续费</view>
							<view class="des">{{ item.feet_money }}</view>
						</view>
						<view class="info">
							<view class="label">实际到账金额</view>
							<view class="des">{{ (item.arrival_money) }}</view>
						</view>
						<view class="info">
							<view class="label">提现账户</view>
							<view class="des">{{ item.account | conceal(4) }}</view>
						</view>
						<view class="info">
							<view class="label">状态</view>
							<view class="price">{{ setwithdrawstatus(item.cash_status) }}</view>
						</view>
						<view class="info">
							<view class="label">提现时间</view>
							<view class="des">{{ item.cre_date }}</view>
						</view>
					</view>
				</view>
				<view class="initNoData" v-if="withdrawList.length == 0">—暂无内容—</view>
			<!-- </scroll-view> -->
	</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			// 提现状态;1:已提现，2:审核中
			withdrawList: [],
			lastId: 0,
			pageIndex: 1,
			pageSize: 10,
			isShowPage: false,
			cashType:'',
			pagesPath:'',
		}
	},
	computed: {
		// 00-待处理02-处理中04-已撤销08-处理失败09-处理成功
		setwithdrawstatus() {
			return function (msg) {
				switch (msg) {
					case '00':
						return '待处理'
						break;
					case '01':
						return '待审核'
						break;
					case '02':
						return '处理中'
						break;
					case '04':
						return '已撤销'
						break;
					case '08':
						return '处理失败'
						break;
					case '09':
						return '处理成功'
						break;
				}
			}
		},
		setwithdrawstyle() {
			return function (msg) {
				switch (msg) {
					case '00':
						return '#B66D3A'
						break;
					case '08':
						return '#15C775'
						break;
					case '09':
						return '#F42D41'
						break;
				}
			}
		}
	},
	onLoad(options) {
		if(options){
			this.cashType = options.value1
			this.init();
		}
	},
	// 下拉刷新
  onPullDownRefresh() {
    console.log('refresh');
    this.init();
    this.isLoadShow = true;
    setTimeout(function () {
      uni.stopPullDownRefresh();
    }, 500);
  },
	onReachBottom() {
    console.log("分页");
    if (this.lsShow == true) {
      this.getRecord();
    } else {
      // return this.$tools.toast('到底了');
    }
  },
	methods: {
		init() {
			this.isShowPage = false,
			this.lastId = '';
			this.withdrawList = [];
			this.getRecord();
		},
		// 奖励来源列表
		getRecord() {
			let that = this;
			const data = {
				cash_type:this.cashType,
				last_id: this.lastId
			}
			console.log("data", data);
			uni.showLoading({
				mask: true
			})
			that.$Ajax('/api/wallet/cash/getUserCashList', data, res => {
				uni.hideLoading();
				this.isShowPage = true;
				if (res.success) {
					that.withdrawList = that.withdrawList.concat(res.data.cashRecordList);
					console.log("that.withdrawList:", that.withdrawList);
					if (res.data.cashRecordList.length > 0) {
						this.lastId = res.data.cashRecordList[res.data.cashRecordList.length - 1].id
						this.lsShow = true
					} else {
						this.lsShow = false
					}
				}
			}, err => {
				uni.hideLoading();
				this.isShowPage = true;
			})
		},
		lower(e) {
			console.log("分页");
			if (this.lsShow == true) {
				this.getWithdrawList();
			} else {
				// return this.$tools.toast('到底了');
			}
		},
	}
}
</script>

<style scoped lang="scss">
.withdrawlog {
	&-container {
		width: 100%;
		min-height: 100vh;
		overflow: auto;
	}

	&-scroll {
		overflow: hidden;
		padding-bottom: 40rpx;
	}

	&-list {
	}

	&-item {
		overflow: hidden;
		width: 93.6%;
		margin: auto;
		background: #fff;
		border-radius: 16rpx;
		padding: 32rpx 0;
		margin-top: 24rpx;
		font-size: 24rpx;
		color: #000000;
		.top {
			@include flexBetween;
			padding: 0 28rpx;
			padding-bottom: 32rpx;
			border-bottom: 1px solid rgba(0, 0, 0, 0.08);

			.name {
				font-size: 28rpx;
			}
		}

		.ico {
			width: 32rpx;
			height: 32rpx;
			display: inline-block;
			vertical-align: middle;
			margin-left: 8rpx;
		}

		.info {
			@include flexBetween;
			padding: 0 28rpx;
			margin-top: 24rpx;
			font-size: 28rpx;

			.txt {
				color: #333;
				font-weight: bold;
			}

			.label {
				color: #999999;
			}

			.des {
				color: #333;
			}

			.price {
				color: #AD2926;
			}
		}
		.info:nth-of-type(1) {
			margin-top: 0;
		}
	}

	&-item:last-of-type {
		border-bottom: none;
	}
}
</style>
